/*
 * This class tests the IScheduleParser
 * with .csv files of the expected format.
 */
package parsers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.Before;
import org.junit.Test;

import data.ClassSlot;
import data.TimeSlot;

/**
 * @author Harmandeep Singh
 * @version 1.0
 * @date May 14, 2011
 * started test
 * @version 1.1
 * @date May 18, 2011
 * Added testing of credits field
 */
public class ScheduleParserTest {

	ScheduleParser parser;
	ClassSlot CS0;
	TimeSlot TS0;
	ClassSlot CStba;
	TimeSlot TStba;
	
	
	 @Before
	  public void setUp() throws Exception 
	  {
		 parser = new ScheduleParser("csv.csv");
		 List<ClassSlot> CSL = parser.getClassSlotList();
		 CS0 = CSL.get(0);
		 TS0 = CS0.getTimeSlot();
		 CStba = CSL.get(CSL.size() - 1);
		 TStba = CStba.getTimeSlot();
	  }
	 
	@Test
	public void testIsTBA() 
	{
		for (int i = 0; i <= 6; i++)
		{
			assertTrue(parser.isTBA("TBA", i));
		}
	}
	
	@Test
	public void testParsingSingleLine()
	{
		assertEquals(TS0.getDays().toString(),"[Wednesday, Monday]");
		assertEquals(TS0.getStartTime(),830);
		assertEquals(TS0.getEndTime(),1035);
		assertEquals(CS0.getClassCredits(),5);
		assertEquals(CS0.getClassNum(),"TCSS305");
		assertEquals(CS0.getClassSection(),'A');
		assertEquals(CS0.getClassTeacher(),"ZIMMERMAN");
		assertEquals(CS0.getClassTitle(),"PROGRAMMING PRACTICUM");
	}
	
	@Test
	public void testAllTBA()
	{
		assertTrue(TStba.getDays().isEmpty());
		assertEquals(TStba.getStartTime(),0);
		assertEquals(TStba.getEndTime(),0);
		assertEquals(CStba.getClassCredits(),0);
		assertEquals(CStba.getClassNum(), null);
		assertEquals(CStba.getClassSection(),' ');
		assertEquals(CStba.getClassTeacher(),null);
		assertEquals(CStba.getClassTitle(), null);
	}
}
